home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright 1999 Macromedia, Inc. All rights reserved.
- //
- //file.js
- //
- //Library of functions pertaining to file functions.
- //
- //--------------------------------------------------------------
- //
- //browseFile(fieldToStoreURL){
- //function getFullPath(filePathURL){
-
-
- //Invokes dialog to allow user to select filename. Puts value in text input.
-
- function browseFile(fieldToStoreURL){
- var fileName = "";
- fileName = browseForFileURL(); //returns a local filename
- if (fileName) fieldToStoreURL.value = fileName;
- }
-
-
- //function: getFullPath
- //description: converts relative paths into full paths that start with
- //file:///
- //Why this is important: A user is prompted for a location to save
- //a file. Dreamweaver generates a path that is relative to the currently
- //opened document. If a developer tries to use this URL in DWfile, it will
- //not work because dreamweaver assumes the path to be relative to the
- //extension file. However, full paths will work
- //Note that this function sometimes returns a full path that is indirect:
- //For instance: file:///C|/MyWebSite/Hobbies/Cooking/.../Hobbies/Images/cake.gif
- //However, the user never sees this file path.
- //
- //Arguments:
- //filePathURL - doc-relative,site-relative, or absolute file path
-
- function getFullPath(filePathURL){
- var retVal = (filePathURL)?filePathURL:'';
- var docURL;
- var dotDotSlash;
- var inMiddle;
-
- if (retVal != ''){
- //if the document path is relative, for example,My Docs/My Schedule.htm
- //create an absolute path.
- if ( filePathURL.indexOf("file://")!=0 ){
-
- //if doc relative...
- if ( filePathURL.charAt(0)!="/" ){
- docURL = dreamweaver.getDocumentDOM('document').URL;
- dotDotSlash = filePathURL.indexOf('../');
- while (dotDotSlash == 0){
- docURL = docURL.substring(0,docURL.lastIndexOf("/"));
- filePathURL = filePathURL.substring(3);
- dotDotSlash = filePathURL.indexOf('../');
- }
- retVal = docURL.substring(0,docURL.lastIndexOf("/")+1) + filePathURL;
- //else path is site relative...
- } else {
- retVal = dreamweaver.getSiteRoot() + filePathURL.substring(1);
- }
- }
- }
- return retVal;
- }
-
-